package com.optimize_01.service.impl;

import com.optimize_01.Subject;
import com.optimize_01.service.DisplayElement;
import com.optimize_01.service.Observer;

public class CurrentConditionsDisplay implements Observer, DisplayElement {

    private float temperature;
    private float humidity;
    private float pressure;
    // private Subject weatherData;

    public CurrentConditionsDisplay(Subject weatherData) {
        // this.weatherData = weatherData;
        weatherData.registerObserver(this);
    }

    @Override
    public void display() {
        System.out.println("temperature: " + temperature + "   humidity: " + humidity + "   pressure:" + pressure);
    }

    @Override
    public void update(float temp, float humidity, float pressure) {
        this.temperature = temp;
        this.humidity = humidity;
        this.pressure = pressure;
        display();
    }
}
